<?php
/**
 * Klasse zum erstellen eines GridColumn
 *
 * @author		Joachim Ruf, Loresoft Software (http://www.loresoft.de)
 * @license		New BSD License
 * @version		Class for Bootstrap v2.3.2
 *
 * */


Class Bootstrap_Grid_Column
{
	private $size				= NULL;
	private $offset				= NULL;
	private $content			= NULL;
	private $arrParam			= array();


	/**
	 * @param string $_size		: breite {1-12}
	 * @param string $_content	: Auszugebender Content
	 * */
	function __construct ($_size = 1, $_content = NULL, $_offset = NULL, array $_arrParam = array()) {
		if (!is_numeric($_size)) {
			return NULL;
		}
		if (!is_array($_arrParam)) {
			return NULL;
		}
		if (is_numeric($_offset)) {
			$this->offset	= $_offset;
		}

		$this->size		= $_size;
		$this->content	= $_content;
		$this->arrParam	= $_arrParam;
	}


	private function getParameter ($_class, array $_arrParam) {
		$result	= NULL;

		if (isset($_arrParam['class'])) { // Class-Parameter verbinden
			$_arrParam['class']	= $_arrParam['class'].' '.$_class;
		} else {
			$_arrParam['class']	= $_class;
		}

		foreach ($_arrParam as $key => $val) {
			$result	.= ' '.$key.'="'.$val.'"';
		}

		return $result;
	}


	/**
	 * Liefert den Content zurueck
	 * @return int
	 * */
	public function getContent() {
		return $this->content;
	}


	/**
	 * Liefert die Elementbreite zurueck {1-12}
	 * @return int
	 * */
	public function getSize() {
		return $this->size;
	}


	/**
	 * @desc Gibt ein Grid-Column aus.
	 * @return string
	 * */
	public function display() {
		$offset	= NULL;
		if ($this->offset !== NULL) {
			$offset	= ' offset'.$this->offset;
		}

		return '<div'.$this->getParameter('span'.$this->size.$offset, $this->arrParam).'>
					'.$this->content.'
				</div>';
	}


}


?>